//package com.pubinfo.passbook.common.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
//import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
//import org.apache.shiro.web.util.WebUtils;
//import org.springframework.util.StringUtils;
//
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpSession;
//import java.io.Serializable;
//
//@Slf4j
//public class MySessionManager extends DefaultWebSessionManager {
//
//  private static final String AUTHORIZATION = "token";
//  private static final String REFERENCED_SESSION_ID_SOURCE = "Stateless request";
//
//  public MySessionManager() {
//    super();
//  }
//
//  @Override
//  protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
//    //前端ajax的headers中必须传入Authorization的值
//    //  String id = WebUtils.toHttp(request).getHeader(AUTHORIZATION);
//    HttpServletRequest servletRequest = WebUtils.toHttp(request);
//
//    Serializable serializable = super.getSessionId(request, response);
//    //如果请求头中有 Authorization 则其值为sessionId
////    if (session!=null&&!StringUtils.isEmpty(session.getId())) {
////      request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE, REFERENCED_SESSION_ID_SOURCE);
////      request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, session.getId());
////      request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
////    //  String loginName = session.getAttribute("loginName").toString();
////      return session.getId();
////    } else {
//    //否则按默认规则从cookie取sessionId
//    return super.getSessionId(request, response);
//    //  }
//  }
//}